<template>
  <div class="tobeDone">
    <tableIndex
      :tableData="tableData"
      :tableHead="tableHead"
      :isIndex="true"
      :isSelection="true"
      :isRadio="false"
      :fields="fields"
      :height="500"
      :page="page"
      @selectChange="selectChange"
      @searchList="searchList"
      @page-change="pageChange"
    >
      <template #btns>
        <div style="float: right">
          <el-button size="small" plain class="update" @click="addHandler"
            ><svg-icon icon-class="add-icon" />添加</el-button
          >
          <el-button size="small" plain class="update"
            ><svg-icon icon-class="export" />一键导出</el-button
          >
        </div>
      </template>

      <template #operate>
        <el-table-column label="操作" width="200" align="center" fixed="right">
          <template #default="{ row }">
            <el-button
              size="small"
              class="update"
              @click="issueHandler(row)"
              type="primary"
              >下发</el-button
            >
            <el-button
              size="small"
              class="update"
              @click="lookItemHandler(row)"
              type="primary"
              >查看</el-button
            >
            <el-button
              size="small"
              class="update"
              @click="updateHandler(row)"
              type="primary"
              >编辑</el-button
            >



          </template>
        </el-table-column>
      </template>
    </tableIndex>


   <!-- 查看弹窗 工作周报 -->
   <view-popover  ref="viewPopoverRef"></view-popover>
  </div>
</template>

<script setup>
import tableIndex from '@/components/table/index.vue'
import ViewPopover from '@/views/constructionProjectManage/weeklyReport/components/ViewPopover.vue';
import { projectApi, projectListApi } from '@/api/project'
import { useRouter } from 'vue-router'
import { ref, onMounted, reactive } from 'vue'

import { ElButton, ElInput, ElMessageBox, ElMessage } from 'element-plus'
const page = reactive({
  page: 1,
  pageSize: 10,
  total: 0
})
const fields = ref([
  {
    key: 'projectName',
    label: '日期',
    type: 'input',
    placeholder: '会议名称关键字搜索'
  },
])
let tableData = ref([])
let tableHead = ref([
  {
    prop: 'projectSetName',
    label: '名称',
    width: '180'
  },
  {
    prop: 'departmentName',
    label: '时间范围',
    width: '120'
  },
  {
    prop: 'streetName',
    label: '已填写人数/总数'
  },
  {
    prop: 'totalProjectAmount',
    label: '截止时间'
  },
  {
    prop: 'createTime',
    label: '创建时间'
  },
  {
    prop: 'createTime',
    label: '创建人'
  },
  {
    prop: 'createTime',
    label: '状态'
  },
])
let activeName = ref('0')

const selectChange = (e) => {
  console.log(e)
}

//路由跳转
let router = useRouter()





const addHandler = () => {
  addPopoverRef.value.open()
}
const viewPopoverRef = ref(null)
//查看
const lookItemHandler = (row) => {
  viewPopoverRef.value.open({type:'公司'})
}

//编辑 建设项目立项  招标 投资 用章用印
const updateHandler = (row) => {
}
// 下发
const issueHandler = (row) => {
}


//搜索接口请求
const searchList = (e) => {
  getPage(e)
}
//分页接口请求
const getPage = (e) => {
  projectApi
    .getAssetsPage({
      pageNum: page.page,
      pageSize: page.pageSize,
      param: e
    })
    .then((res) => {
      if (res.code == 200) {
        tableData.value = res.data.content
        page.total = res.data.totalSize
        console.log(tableData)
      }
    })
}
//分页
const pageChange = (e) => {
  console.log(e)
  page.page = e.page
  page.pageSize = e.limit

  getPage(page)
}

onMounted(() => {
  getPage()
})
</script>

<style lang="scss" scoped>
.tobeDone {
  width: 100%;
  height: 100%;
}
</style>
